<template>
	<view class="content">
		<swiper class="swiper" circular :indicator-dots="true" :autoplay="true" :interval="3000"
			:duration="500">
			<swiper-item v-for="item in list" :key="item.bannerid">
				<view class="swiper-item uni-bg-red">
					<image :src="item.img" mode=""></image>
				</view>
			</swiper-item>
		</swiper>
		
		<view class="navWrap">
			<view class="navItem" v-for="item in navlist" :key="item.navid">
				<image :src="item.imgurl" mode=""></image>
				<text>{{item.title}}</text>
			</view>
		</view>
		
		<view class="contentWrap">
			<view class="contentItem" v-for="item in proList" :key="item.proid" @click="goToDetail(item.proid)">
				{{ item.proname }}
			</view>
		</view>
	</view>
</template>

<script>
	import navlist from "../../assets/navlist.js"
	export default {
		data() {
			return {
				list: [],
				navlist,
				proList: [],
				page: 1
			}
		},
		onLoad() {
			this.getBannerList();
			this.getProList();
		},
		onReachBottom() {
			this.getProList();
		},
		methods: {
			getBannerList() {
				uni.request({
				    url: 'http://121.89.205.189:3000/api/banner/list', //仅为示例，并非真实接口地址。
				    data: {},
				    header: {
				        "content-type": "application/json"
				    },
				    success: (res) => {
				        this.list = res.data.data;
				    }
				});
			},
			getProList() {
				uni.request({
				    url: 'http://121.89.205.189:3000/api/pro/list', //仅为示例，并非真实接口地址。
				    data: {
						count: this.page,
						limitNum: 10,
					},
				    header: {
				        "content-type": "application/json"
				    },
				    success: (res) => {
				        this.proList = [...this.proList, ...res.data.data];
						this.page++;
				    }
				});
			},
			goToDetail(id) {
				uni.navigateTo({
					url: "../../packageA/pages/detail/detail?id=" + id
				})
			}
		}
	}
</script>

<style>
	swiper {
		height: 400rpx;
	}
	.swiper-item {
		width: 100%;
		height: 100%;
	}
	swiper image {
		width: 100%;
		height: 100%;
	}
	
	.navWrap {
		width: 100%;
		height:300rpx;
		display: flex;
		flex-wrap: wrap;
	}
	.navItem {
		width: 20%;
		border:1rpx solid #ccc;
		box-sizing: border-box;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}
	.navItem image {
		width: 75rpx;
		height:75rpx;
	}
	.navItem text {
		
	}
	
	.contentItem {
		width: 100%;
		height: 200rpx;
		border-bottom: 1rpx solid #ccc;
	}
</style>
